package com.xhwl.centiotdata.service.cent;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhwl.centiotdata.service.integrateconfig.DeviceProjSupplierCategoryDTO;
import com.xhwl.common.dto.cent.device.DeviceDTO;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.device.*;
import com.xhwl.common.query.cent.device.*;
import com.xhwl.common.vo.cent.device.DeviceProjSupplierCategoryVO;
import feign.Param;
import feign.RequestLine;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @Author： lianghz
 * @Description：
 * @Date 2021/09/06/ 09:55
 */
@FeignClient(name = "cent-device")
public interface IDeviceCentService {

    @RequestLine(value = "POST /product-access-service/list")
    List<DeviceProjSupplierCategory> listProductAccess(@Param("industryId") Short industryId, @Param("productAccessQuery") ProductAccessQuery productAccessQuery);

    @RequestLine(value = "POST /product-access-service/page")
    Page<DeviceProjSupplierCategoryVO> onListingDeviceSupplierCategoryVO(
            @Param("page") Page page,
            @Param("integrationConfigQuery") IntegrationConfigQuery integrationConfigQuery
    );

    /**
     * 根据三方id前缀查找
     *
     * @param idPrefix
     * @return
     */
    @RequestLine(value = "POST /device-service/get-by-thirdId")
    Device getByThirdIdPrefix(@Param("idPrefix") String idPrefix);

    @RequestLine(value = "POST /device-service/list")
    List<DeviceDTO> list(@Param("industryId") Short industryId, @Param("deviceQuery") DeviceQuery deviceQuery);

    @RequestLine(value = "POST /device-service/async-update-device")
    ResultJson asyncUpdateDevice(@Param("deviceDTOList") List<DeviceDTO> deviceDTOList);

    @RequestLine(value = "POST /device-service/async-update-device/v2")
    ResultJson asyncUpdateDeviceV2(@Param("deviceDTOList") List<DeviceDTO> deviceDTOList);

    @RequestLine(value = "POST /device-service/async-update-onlinestatus")
    ResultJson asyncUpdateOnlineStatus(@Param("deviceList") List<Device> deviceList);

    @RequestLine(value = "POST /device-service/list")
    List<DeviceDTO> listDevice(@Param("industryId") Short industryId, @Param("deviceQuery") DeviceQuery deviceQuery);

    @RequestLine(value = "POST /device-service/batch-save")
    ResultJson batchSave(@Param("industryId") Short industryId, @Param("devices") List<Device> devices);

    /**
     * 该接口有问题（会删除整个表数据）
     *
     * @param deviceQuery
     * @return
     */
    @Deprecated
    @RequestLine(value = "POST /device-service/delete-by-iotId")
    boolean deleteByIotId(@Param("deviceQuery") DeviceQuery deviceQuery);

    @RequestLine(value = "POST /v2/device-service/delete-by-iotId")
    boolean deleteByIotIdV2(@Param("deviceQuery") DeviceQuery deviceQuery);

    @RequestLine(value = "POST /device-status-record/save")
    boolean saveRecord(@Param("deviceStatusRecord") DeviceStatusRecord deviceStatusRecord);

    @RequestLine(value = "POST /device-service/list-device")
    List<DeviceDTO> listDevice(@Param("industryId") Short industryId, @Param("devicePageQuery") DevicePageQuery devicePageQuery);

    @RequestLine(value = "POST /device-service/page-device")
    Page<DeviceDTO> pageDevice(@Param("industryId") Short industryId, @Param("devicePageQuery") DevicePageQuery devicePageQuery);

    @RequestLine(value = "POST /device-service/batchupdate")
    ResultJson batchUpdate(@Param("industryId") Short industryId, @Param("dtos") List<DeviceDTO> dtos);

    @RequestLine(value = "POST /device-service/update-online-status")
    boolean update(@RequestBody Device device);

    @RequestLine(value = "POST /device-service/async-batch-update-status")
    void batchUpdateStatus(@RequestBody List<Device> deviceList);

    /**
     * 通知device中台同步离线设备数据
     *
     * @return
     */
    @RequestLine("POST /device-service/sync-offline-device")
    ResultJson syncOfflineDevice();

    /**
     * 查询项目下拥有的的设备类型详情列表
     */
    @RequestLine(value = "POST /device-type-service/list")
    ResultJson<List<DeviceType>> getDeviceTypes(@Param("deviceTypeQuery") DeviceTypeQuery deviceTypeQuery);

    /**
     * 获取所有设备类型
     *
     * @return
     */
    @RequestLine(value = "POST /prod-category/type/service")
    List<DeviceProductCategory> listCategory();

    /**
     * 根据设备组查询设备id
     * @param deviceGroupQuery
     * @return
     */
    @RequestLine(value = "POST /device-group-service/query-relation")
    Page<Device> queryRelation(@Param("deviceGroupQuery") DeviceGroupQuery deviceGroupQuery);

}
